package cn.tansanqinger.service.impl;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.tansanqinger.dao.sql.impl.LoginSqlDaoImpl;
import cn.tansanqinger.pojo.Admin;
import cn.tansanqinger.service.LoginService;
import cn.tansanqinger.util.Encoder_Dispose;

@Service
public class LoginServiceImpl implements LoginService{
	
	@Autowired
	private LoginSqlDaoImpl loginImpl;

	@Override
	public String AccountPasswdIsConsistent(HttpServletRequest request, String account, String passwd) {
		if(Encoder_Dispose.isNull(account,passwd)) {
			Admin admin = loginImpl.selectAdminAcount(account);
			if(admin!=null) {
				if(Encoder_Dispose.encoderMD5(passwd).equals(admin.getPasswd())) {
					request.getSession().setAttribute("userMessage", admin);
					return "success";
				}
			}
		}
		return "usererror";
	}

}
